from django.contrib.auth.models import User, Group
#  我们把公共的view行为归到同一个类中,叫做viewsets
from rest_framework import viewsets
from quickstart.serializers import UserSerializer, GroupSerializer, loginOAuthSerializer
from quickstart.models import loginOAuth


class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer


class GroupViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows groups to be viewed or edited.
    """
    queryset = Group.objects.all()
    serializer_class = GroupSerializer

class loginOAuthViewSet(viewsets.ModelViewSet):
    serializer_class = loginOAuthSerializer
    queryset = loginOAuth.objects.all()
